﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using ModuleDALCore;
using DTO;
namespace DAL
{
    public class DANHMUCLABODAO:DALBase
    {
        public DANHMUCLABODAO()
        {
            this.OpenConnect();
        }
        private DataTable dt;
        private string _SpName;

        public string SpName
        {
            get { return "SPDANHMUCLABO"; }
            set { _SpName = value; }
        }
        public DataTable GetListLB(DANHMUCLABO bm)
        {
            dt = new DataTable();
            try
            {

                dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(bm, null), ConvertClassToArray.GetValues(bm, 0));
                return dt;
            }
			catch { return null; }
        }
        public String CreatenewId()
        {
            try
            {
                return "LB" + DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(new DANHMUCLABO(), null), ConvertClassToArray.GetValues(new DANHMUCLABO(), 1));

            }
			catch { return null; }
        }
        public bool INSERT(DANHMUCLABO cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 2)) == 1);

            }
			catch { return false; }
        }
        public bool UPDATE(DANHMUCLABO cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 3)) == 1);

            }
			catch { return false; }
        }
        public bool DELETE(DANHMUCLABO cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 4)) == 1);

            }
			catch { return false; }
        }
        public DANHMUCLABO Find(DANHMUCLABO bm)
        {
            dt = new DataTable();
            DANHMUCLABO lb = new DANHMUCLABO();
            try
            {
                dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(bm, null), ConvertClassToArray.GetValues(bm, 5));
                lb =(DANHMUCLABO) ConvertDatatableToList.ConvertToObject<DANHMUCLABO>(dt);
            }
			catch { return null; }
            return lb;
        }
		public List<DANHMUCLABO> FindtheoMNCC(DANHMUCLABO bm)
		{
			dt = new DataTable();
			List<DANHMUCLABO> lb = new List<DANHMUCLABO>();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(bm, null), ConvertClassToArray.GetValues(bm, 6));
				lb = (List<DANHMUCLABO>)ConvertDatatableToList.ConvertTo<DANHMUCLABO>(dt);
			}
			catch { return null; }
			return lb;
		}
    }
}
